import baseUrl from "./baseUrl.js";
import request from "@/utils/http.request.js";

const role = {

    /**
     * 获取角色分页列表
     * @param pageIndex 当前页
     * @param pageSize
     * @param keyword 关键字     
     * @param _response 
     * @param _finally 
     * @returns 
     */
    pageList(pageIndex, pageSize, keyword, _response, _finally = null) {
        return request.get(`${baseUrl.role}/pagelist`, { pageIndex: pageIndex, pageSize: pageSize, keyword: keyword }, _response, _finally);
    },
    /**
     * 获取角色列表       
     * @param _response 
     * @param _finally 
     * @returns 
     */
    list(_response, _finally = null) {
        return request.getWithoutParam(`${baseUrl.role}/list`, _response, _finally);
    },
    /**
 * 获取角色信息。
 * @param roleId 角色Id
 * @param _response 
 * @param _finally 
 * @returns 
 */
    get(roleId, _response, _finally = null) {
        return request.getWithoutParam(`${baseUrl.role}/${roleId}`, _response, _finally);
    },
    /**
     * 添加角色信息
     * @param roleName 角色名称       
     * @param bak 备注
     * @param permissionIds 权限Ids
     * @param _response 
     * @param _finally 
     * @returns 
     */
    add(roleName, bak, permissionIds, _response, _finally = null) {
        return request.postWithJson(`${baseUrl.role}`, { roleName: roleName, bak: bak, permissionIds: permissionIds }, _response, _finally);
    },
    /**
     * 修改角色信息
     * @param roleId 角色id
     * @param roleName 角色名称    
     * @param bak 备注     
     * @param permissionIds 权限Ids
     * @param _response 
     * @param _finally 
     * @returns 
     */
    edit(roleId, roleName, bak, permissionIds, _response, _finally = null) {
        return request.putWithJson(`${baseUrl.role}`, { roleId: roleId, roleName: roleName, bak: bak, permissionIds: permissionIds }, _response, _finally);
    },
    /**
     * 删除角色
     * @param roleId 角色id
     * @param _response 
     * @param _finally 
     * @returns 
     */
    delete(roleId, _response, _finally = null) {
        return request.deleteWithouParam(`${baseUrl.role}/${roleId}`, _response, _finally)
    }

};

export default role;